package leetcode.medium.limit100;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author yaoyao1.liu@zhaopin.com.cn
 * @since 2022-11-10 16:32
 **/
public class No73 {

    public static void main(String[] args) {
        No73 no73 = new No73();
        int[][] ints = new int[][]{{1, 1, 1}, {1, 0, 1}, {1, 1, 1}};
        no73.setZeroes(ints);
        System.out.println(Arrays.deepToString(ints));

    }
    public void setZeroes(int[][] matrix) {

        List<int[]> list = new ArrayList<>();
        for (int i = 0; i < matrix.length; i++) {
            for (int i1 = 0; i1 < matrix[i].length; i1++) {
                int num = matrix[i][i1];
                if (num == 0) {
                    list.add(new int[]{i, i1});
                }
            }
        }
        for (int i = 0; i < matrix.length; i++) {
            for (int i1 = 0; i1 < matrix[i].length; i1++) {
                for (int[] ints : list) {
                    int anInt = ints[0];
                    int anInt1 = ints[1];
                    if (i == anInt || anInt1 == i1) {
                        matrix[i][i1] = 0;
                        break;
                    }
                }
            }
        }
    }
}
